# Build stage
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Run stage
FROM nginx:1.27-alpine
# 拷贝构建产物
COPY --from=build /app/dist/ /usr/share/nginx/html/
# 使用自定义配置
COPY nginx.conf /etc/nginx/conf.d/default.conf

# 共享后端静态和媒体
VOLUME ["/vol/static", "/vol/media"]

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]